package ch.mobi.osgi2maven2;

import java.util.List;

import ch.mobi.osgi2maven.config.PredefinedDependencies;
import ch.mobi.osgi2maven2.osgi.OsgiBundle;
import ch.mobi.osgi2maven2.osgi.OsgiResolver;
import ch.mobi.osgi2maven2.osgi.RequiredBundle;
import ch.mobi.osgi2maven2.pom.PomDependency;
import ch.mobi.osgi2maven2.pom.PomFile;

public class PomCreator {

	private final OsgiResolver resolver;
	private final PredefinedDependencies predefined;
	private final String groupId;

	public PomCreator(OsgiResolver resolver, PredefinedDependencies predefined, String groupId) {
		this.resolver = resolver;
		this.predefined = predefined;
		this.groupId = groupId;

	}

	public PomFile createPom(OsgiBundle bundle) {

		PomFile ret = new PomFile(groupId, bundle.getBundleName(), bundle.getVersion().toString());

		List<RequiredBundle> resolved = bundle.getRequiredBundles();

		for (RequiredBundle file : resolved) {
			PomDependency dependency = new PomDependency(groupId, file.getSymbolicName(), file.getVersionRange().toParseString(), false);
			ret.getDependencies().add(dependency);
		}

		return ret;

	}

}
